/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.service.ConnectionUtils;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author KIRAN
 */
public class ConnectionFactory {
  static String 
driverClassName="oracle.jdbc.driver.OracleDriver";
                static String url="jdbc:oracle:thin:@localhost:1522:xe";
                static String username="system";
                static String password="kiran";
                Connection con=null;
                public static Connection getConnection() 
                {

                        //Class c=Class.forName(driverClassName);
//                      Driver d=(Driver)c.newInstance();
//                      // Obtain a connection
//                      Properties p=new  Properties();
//                      p.put("username",username);
//                      p.put("password", password);
//                      Connection con=d.connect(url,p);
                        try {
                                Class.forName(driverClassName);
                        } catch (Exception e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
                        Connection con = null;
                        try {
                                con = 
DriverManager.getConnection(url,username,password);
                        } catch (Exception e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }

                        
                        return con;
                }
                public static void close(Connection con) {
                        try {
                                con.close();
                        } catch (SQLException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
                }
  
}
